package com.example.test2.controller;


import com.example.test2.dao.course;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

@Controller
@RequestMapping("/student")
public class myController {

    @RequestMapping("/information")
    public String MyInformation(){
        return "stuInformation";
    }

    @RequestMapping("/select")
    public String selectClass(){
        return "select";
    }

    @RequestMapping("/check")
    public String selectedClass(){
        return "selected";
    }

    @RequestMapping("/selected")
    public String selected(@RequestParam("courseName")String[] courseName,
                           @RequestParam("credit")String[] credit,Model model){

        System.out.println("hhhhhhhhhhhhhh");
        //声明一个集合
        ArrayList<course> courses = new ArrayList<>();

        for (int i =0;i<courseName.length;i++){
            course course = new course();
            course.setCourseName(courseName[i]);
            course.setCredit(credit[i]);
            courses.add(course);
        }
        model.addAttribute("mycourse",courses);

        return "selected";
    }



}
